<script setup>
import { ref } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { ActionBar, ActionBarIcon, ActionBarButton, NavBar } from 'vant'
import { loadProductByIdAPI } from '../api/products'

const route = useRoute()
const router = useRouter()
const proudct = ref({})
loadProductByIdAPI(route.query.id).then(res => proudct.value = res.data)

const onClickIcon = () => { }
const onClickButton = () => { }
const goHOme = () => {
    router.push({ name: 'Home' })
}
const goBack = () => {
    router.go(-1)
}
</script>

<template>
    <div class="detail">
        <nav-bar :title="proudct.name" left-text="返回" left-arrow @click-left="goBack" />
        <h1>{{ proudct.name }}</h1>
        <div class="content" v-html="proudct.content"></div>
        <action-bar>
            <action-bar-icon icon="chat-o" text="客服" @click="onClickIcon" />
            <action-bar-icon icon="cart-o" text="购物车" @click="onClickIcon" />
            <action-bar-icon icon="shop-o" text="店铺" @click="goHOme" />
            <action-bar-button type="danger" text="立即购买" @click="onClickButton" />
        </action-bar>
    </div>
</template>

<style scoped></style>